from flask import Flask


# wsgi 方式请求
def handle_home(environ, start_response):
    body = '<button id="btgo" onclick="goto()">backtomims------</button>' \
           '<script type="text/javascript"> function goto() {window.location.href = "native://backtomims?"; alert("wwww")}</script>'
    return [body.encode('utf-8')]


def handle_signin(environ, start_response):
    body = '<h1>Hello longin, %s!</h1>' % (environ['PATH_INFO'][1:] or 'web')
    return [body.encode('utf-8')]


def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    # body = '<h1>Hello, %s!</h1>' % (environ['PATH_INFO'][1:] or 'web')
    method = environ['REQUEST_METHOD']
    path = environ['PATH_INFO']
    if method == 'GET' and path == '/':
        return handle_home(environ, start_response)
    if method == 'GET' and path == '/signin':
        return handle_signin(environ, start_response)
